<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title>个人信息</title>
	<meta name="renderer" content="webkit">	
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">	
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">	
	<meta name="apple-mobile-web-app-status-bar-style" content="black">	
	<meta name="apple-mobile-web-app-capable" content="yes">	
	<meta name="format-detection" content="telephone=no">	
	<link rel="stylesheet" type="text/css" th:href="@{/static/common/layui/css/layui.css}" media="all">
	<link rel="stylesheet" type="text/css" th:href="@{/static/common/bootstrap/css/bootstrap.css}" media="all">
	<link rel="stylesheet" type="text/css" th:href="@{/static/common/global.css}" media="all">
	<link rel="stylesheet" type="text/css" th:href="@{/static/css/personal.css}" media="all">
	<style>
		#container {width:500px; height: 380px; }
	</style>
</head>
<body>
<input hidden type="text" id="livingBuildingId" th:value="${obj.id}">
<section class="layui-larry-box">
	<div class="larry-personal">
		<div class="larry-personal-body clearfix">
			<form class="layui-form col-lg-5" action="" method="post">
				<div class="layui-form-item">
					<label class="layui-form-label">游戏账号</label>
					<div class="layui-input-block">  
						<input type="text" lay-verify="required" th:value="${obj.accountNumber}" id="accountNumber" placeholder="请输入" name="title" autocomplete="off" class="layui-input">
					</div>
				</div>


				<div class="layui-form-item">
					<label class="layui-form-label">密码</label>
					<div class="layui-input-block">
						<input type="text" lay-verify="required" th:value="${obj.password}" id="password" placeholder="请输入" name="title" autocomplete="off" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">游戏账号</label>
					<div class="layui-input-block">
						<input type="text" lay-verify="required" th:value="${obj.nickName}" id="nickName" placeholder="请输入" name="title" autocomplete="off" class="layui-input">
					</div>
				</div>


				<div class="layui-form-item">
					<label class="layui-form-label">图片预览</label>
					<div class="layui-input-inline">
						<img id="image_upload" style="width: 300px;height: 200px" th:src="${obj.faceImg}">
					</div>
				</div>
				<div id="submit_btn_div" class="layui-form-item">
					<div class="layui-input-block">
						<button id="submit_btn" type="button" class="layui-btn">立即提交</button>
						<button id="clear_btn" type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</section>
<script type="text/javascript" th:src="@{/static/js/jquery-1.9.1.min.js}"></script>
<script type="text/javascript" th:src="@{/static/common/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/static/js/gdmap.js}"></script>
<!--<script src="https://webapi.amap.com/maps?v=1.4.15&key=234f864ce0d2ff95e8ebaf21a384d913&callback=init"></script>-->
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=KV5BZ-M7HCX-ALZ45-7QARP-4W6XH-SFFAO"></script>
<script type="text/javascript">
	layui.use(['form','upload','layedit','jquery','layer'],function(){
        var $ = layui.$;
        var layer = layui.layer;
        //建立编辑器
		 layui.upload({
			 accept: 'images',
			 acceptMime: 'image/*',
			 url: '/mapmanagement/map/livingBuilding/file/upload' ,//上传接口
			 before:function(inputObj){
				var size = inputObj.files[0].size;
				if (size > (1*1024*1024)){
				    layer.msg('图片大小不得超过1M',{icon:2});
				    return;
				}
				if (size == 0){
                    layer.msg('图片大小不得为空',{icon:2});
                    return;
				}
			 },
			 success: function(res){
			  //上传成功后的回调
			  if (res.code == 500){
                  layer.alert(res.msg,function(){
                      layer.close(layer.index);
                  })
			  }else {
                  $("#image_upload").attr("src",res.data.src);
                  $("#image_upload").css("width","300px");
                  $("#image_upload").css("height","200px");
			  }
			}
		 });

        $("#submit_btn").on("click",function () {
            //提交按钮
			var id = $("#livingBuildingId").val();
            var accountNumber = $("#accountNumber").val();
            var imageFile = $("#image_upload").attr("src");
            var password = $("#password").val();
            var nickName = $("#nickName").val();
            $.ajax({
                url:"/mapmanagement/map/livingBuilding/edit",
                data:{
                    'id': id,
                    'accountNumber': accountNumber,
                    'imageFile':imageFile,
                    'password':password,
                    'nickName':nickName,
                },
                method:'post',
                dataType:'json',
                traditional:true,
                success: function (data) {
                    console.log(data);
                    if (data.code == 500){
                        layer.alert(data.msg, function () {
                            layer.close(layer.index);
                        });
					} else {
                        layer.alert(data.msg, function () {
                            layer.close(layer.index);
                            window.location.reload();
                        });
					}
                },
                error:function () {
                    layer.alert("生活楼更新失败", function () {
                        layer.close(layer.index);
                    });
                }
            })
        });
	});





</script>
</body>
</html>